{layout name="public/layout" /}
		{include file='yxnavbar'}
{if $op == 'post'}
<div class="clearfix">
	<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
		<input type="hidden" name="workerid" value="{$item['id']}" id="workerid">
		<div class="panel panel-default">
			<div class="panel-heading">员工信息修改</div>
			<div class="panel-body">
				<div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">微信头像</label>
                    <div class="col-sm-8 col-xs-12">
                        {php echo view_form_field_image('avatar',$item['avatar']);}
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>微信昵称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="nickname" value="{$item['nickname']}" class="form-control">
						<div class="help-block">微信昵称</div>
					</div>
				</div>
                 <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>所在团队</label>
                    <div class="col-sm-8 col-xs-12">
						{if ($system['ruanjian']==3)}
						<div class="col-sm-5 col-lg-5 col-md-5 col-xs-8">
		                    <select class="form-control" name="company"  id="province" onchange="alter(this.selectedIndex)">
				     		 </select>
		                </div>
						<div class="col-sm-5 col-lg-5 col-md-5 col-xs-8">
		                    <select class="form-control" name="team"  id="city">
				     		 </select>
		                </div>
		                {else}
						<div class="col-sm-6 col-lg-6 col-md-6 col-xs-8">
		                    <select class="form-control" name="team">
		               		{loop $teamlist $row}
				         		<option value="{$row['tid']}" {if $item['team']== $row['tid'] }selected="selected"{/if}>{$row['tid']}|{$row['teamname']}</option>
				       		{/loop}
				     		 </select>
		                </div>
		                {/if}
                    </div>
                </div>
                 <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>管理权限</label>
                    <div class="col-sm-8 col-xs-12">
                        <select class="form-control" name="level">
			         		<option value="1" {if $item['level']== 1 }selected="selected"{/if}>超级管理员</option>
			         		<option value="2" {if $item['level']== 2 }selected="selected"{/if}>商家管理员</option>
			         		<option value="3" {if $item['level']== 3 }selected="selected"{/if}>员工</option>
			     		 </select>
			     		 <div class="help-block">超级管理员变更员工时,尽量联系工作人员把密码一起改掉,否则原来的超级管理员知道密码,一样可以改回身份</div>
                    </div>
                </div>
				<div class="form-group" id="username">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="username" value="{$item['username']}" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>电话</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="mobile" value="{$item['mobile']}" class="form-control">
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">微信二维码</label>
                    <div class="col-sm-8 col-xs-12">
                    	{if strlen($item['qrcode'])>200}
                        {php echo view_form_field_image('qrcode','');}
                        <img src="{$item['qrcode']}" width="100px" />
			     		<div class="help-block">需要裁好尺寸200*200px,再上传</div>
                    	{else}
                        {php echo view_form_field_image('qrcode',$item['qrcode']);}
			     		<div class="help-block">需要裁好尺寸200*200px,再上传</div>

			     		{/if}
                    </div>
                </div>
				{if $isposter}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">活动首图</label>
					<div class="col-sm-9 col-xs-12">
						<img src="{$item['poster']}" width="100px" />
						<div class="help-block">提交保存，将会自动生成最新的</div>
					</div>
				</div>
				{/if}
                {if $system['fenxiao04'] ==1 || $system['fenxiao05'] ==1 || $system['fenxiao07'] ==1}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">裂变红包</label>
					<div class="col-sm-9 col-xs-12">
						{if $item['comm4status'] == 0}
							<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $item['id'],'status' => 3));}" class="btn btn-success btn-sm" title="手工锁定" data-toggle="tooltip" data-placement="top">正常</a>
						{elseif $item['comm4status'] == 1}
							<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $item['id'],'status' => 0));}" class="btn btn-success btn-sm" title="系统自动判断" data-toggle="tooltip" data-placement="top">永久正常</a>
						{elseif $item['comm4status'] == 2}
							<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $item['id'],'status' => 1));}" class="btn btn-danger btn-sm" title="永久正常" data-toggle="tooltip" data-placement="top">自动锁定</a>
						{elseif $item['comm4status'] == 3}
							<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $item['id'],'status' => 0));}" class="btn btn-danger btn-sm" title="系统自动判断" data-toggle="tooltip" data-placement="top">手工锁定</a>
						{/if}
					</div>
				</div>
				{/if}
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="openid" value="{$item['openid']}" />
			<input type="hidden" name="__token__" value="{$Request.token}" />
		</div>
	</form>
</div>
<script type="text/javascript">

</script>
{else}
<script type="text/javascript">
function submitForm(){
    var form = document.getElementById("myform");
    form.submit();
}
</script>
<div class="mian">
	<div class="panel panel-info">
		<div class="panel-heading">当前数量： {$total}</div>
		<div class="panel-body">
			<form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">状态</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">
							<a href="{php echo filter_url('status:-1');}" class="btn {if $status == -1}btn-primary{else}btn-default{/if}">不限<span style="color: #ff0000">{$gsum0}</span></a>
							<a href="{php echo filter_url('status:1');}" class="btn {if $status == 1}btn-primary{else}btn-default{/if}">超级管理员<span style="color: #ff0000">{$gsum1}</span></a>
							{if ($system['ruanjian']==3)}
							<a href="{php echo filter_url('status:2');}" class="btn {if $status == 2}btn-primary{else}btn-default{/if}">商家管理员<span style="color: #ff0000">{$gsum2}</span></a>
                    		{/if}
							<a href="{php echo filter_url('status:3');}" class="btn {if $status == 3}btn-primary{else}btn-default{/if}">员工<span style="color: #ff0000">{$gsum3}</span></a>
							<a href="{php echo filter_url('status:4');}" class="btn {if $status == 4}btn-primary{else}btn-default{/if}">无团队<span style="color: #ff0000">{$gsum4}</span></a>
							<a href="{php echo filter_url('status:5');}" class="btn {if $status == 5}btn-primary{else}btn-default{/if}">信息不完整<span style="color: #ff0000">{$gsum5}</span></a>
						</div>
					</div>
					{if count($themelist)>1}
						<div class="col-sm-3 col-xs-3 col-md-3">
							 <select onchange="submitForm();" class="form-control" name="themeid">
	                   		{loop $themelist $row}
				         		<option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
				       		{/loop}
				     		 </select>
			 			</div>
					{else}
						<input type="hidden" name="themeid" value="{$themeid}" /> 
					{/if}
				</div>
                 <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">所在团队</label>
					{if ($system['ruanjian']==3)}
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-4">
                        <select class="form-control" name="company"  id="province" onchange="alter(this.selectedIndex)">
			     		 </select>
                    </div>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-4">
                        <select class="form-control" name="team"  id="city">
			     		 </select>
                    </div>
                    {else}
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-4">
                        <select class="form-control" name="team">
			         		<option value="" >请选择团队</option>
                   		{loop $teamlist $row}
			         		<option value="{$row['tid']}" {if $team[0]== $row['tid'] }selected="selected"{/if}>{$row['tid']}|{$row['teamname']}</option>
			       		{/loop}
			     		 </select>
                    </div>
                    {/if}
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">员工信息</label>
					<div class="col-sm-4 col-lg-4 col-md-4 col-xs-6">
						<input type="text" class="form-control" name="keyword" value="{$_P['keyword']}" />
					</div>
					<div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
						<button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
					<div class="col-sm-2 col-lg-2 col-md-2 col-xs-6">
						<input class="btn btn-default" type="submit" name="export_submit" id="export_submit" value="导出EXCEL">

					</div>

					<div class="col-sm-2 col-lg-2 col-md-2 col-xs-6">
						<a href="{php echo createWebUrl($do, array('op' => 'update','themeid'=>$themeid));}" class="btn btn-danger btn-sm" onclick="if(!confirm('当数据不准确时可以更新，一般不需要此操作！耗时1-5分钟')) return false;"  title="当数据不准确时可以更新，一般不需要此操作！耗时1-5分钟" data-toggle="tooltip" data-placement="top">更新所有员工报表</a>
                    </div>
                    {if $status == 5}
					<div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
						<a href="{php echo createWebUrl($do, array('op' => 'delete5','themeid'=>$themeid));}" class="btn btn-danger btn-sm" onclick="if(!confirm('员工信息不完整的，确认要删除吗？')) return false;"  title="" data-toggle="tooltip" data-placement="top">删除所有信息不完整</a>
                    </div>
                    {/if}
				</div>
			</form>
	</div>
	
		<div class="panel-footer"><span style="color: red" >点击	转发	浏览	新粉丝	直销	成交	线下 可进行排序；</span>{if $freerecord}活动免费报名，成交数为报名数{/if}</div>
	
	</div>

	<form class="form-horizontal" action="" method="post">

		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>ID</th>
							<th >头像</th>
							<th>微信</th>
							<th width="108px">昵称</th>
							{if $system['ruanjian']==3}
							<th>公司</th>
							{/if}
							<th>团队</th>
							<th>姓名</th>
							<th>电话</th>
							<th>身份</th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'forward','themeid'=>$themeid));}">转发</a></th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'scansum','themeid'=>$themeid));}">浏览</a></th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'newfans','themeid'=>$themeid));}">新粉丝</a></th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'record','themeid'=>$themeid));}">成交</a></th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'recordzx','themeid'=>$themeid));}">直销</a></th>
							<th><a href="{php echo createWebUrl('worker',array('paixu' => 'recordxx','themeid'=>$themeid));}">线下</a></th>
							{if $system['fenxiao']==1}
							<th>红包</th>
							<th>收到</th>
							<th>未发</th>
							{/if}
							{if !empty($system['wxapp'])}							
							<th>来自</th>
							{/if}
							<th style="width:150px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $index $row}
						<tr>
							<td>{php echo $index+1;}</td>
							<td  style="font-size: 10px;max-width: 100px;">
								<img src="{php echo tomedia($row['avatar']);}" width="40px" style="bsection-radius: 3px;">
							</td>
							<td>
								{if $system['wxapp']==$row['uniacid'] && empty($row['qrcode'])}
								{$row['wechat']}
								{else}
								<img src="{$row['qrcode']}" width="40px" style="bsection-radius: 3px;">
								{/if}
							</td>
							<td  style="font-size: 10px;max-width: 100px;">
								{$row['nickname']}
							</td>
							{if $system['ruanjian']==3}
							<td style="font-size: 10px;max-width: 100px;"><a href="{php echo createWebUrl('worker',array('themeid'=>$themeid,'companyid'=>$row['company']));}" >{php echo $row['companyname'];}</a></td>
							{/if}
							<td style="font-size: 10px;max-width: 100px;"><a href="{php echo createWebUrl('worker',array('themeid'=>$themeid,'teamid'=>$row['team']));}" >{php echo $row['teamname'];}</a></td>
							<td>
								{$row['username']}
							</td>
							<td>
								{$row['mobile']}
							</td>
							<td>
								{$shenfen[$row['level']]}
							</td>
							<td><span class="label label-info">{$row['forward']}</span></td>
							<td><span class="label label-success">{$row['scansum']}</span></td>
							<td><a href="{php echo createWebUrl('fans',array('themeid'=>$themeid,'workerid'=>$row['uid'],'op'=>'display'));}" class="label label-primary">{$row['newfans']}</a></td>
							<td><a href="{php echo createWebUrl('record',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>1,'op'=>'display','zhijie'=>'true'));}" class="label label-info">{$row['record']}</a></td>
							<td><a href="{php echo createWebUrl('record',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>1,'op'=>'display'));}" class="label label-success">{$row['recordzx']}</a></td>
							<td><a href="{php echo createWebUrl('record',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>1,'op'=>'display'));}" class="label label-success">{$row['recordxx']}</a></td>
							{if $system['fenxiao']==1}
							<td><a href="{php echo createWebUrl('comm',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>1,'op'=>'display','zhijie'=>'true'));}" class="label label-warning">{$row['tj4']}</a></td>	
							<td><a href="{php echo createWebUrl('comm',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>1,'op'=>'display','zhijie'=>'true'));}" class="label label-primary">{$row['tj3']}</a></td>		
							<td><a href="{php echo createWebUrl('comm',array('themeid'=>$themeid,'workerid'=>$row['uid'],'status'=>0,'op'=>'display','zhijie'=>'true'));}" class="label label-default">{$row['tj5']}</a></td>
							{/if}
							<!-- {if $system['fenxiao04'] ==1 || $system['fenxiao05'] ==1 || $system['fenxiao07'] ==1}
							<td>{if $row['comm4status'] == 0}
									<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $row['id'],'status' => 3));}" class="btn btn-success btn-sm" title="手工锁定" data-toggle="tooltip" data-placement="top">正常</a>
								{elseif $row['comm4status'] == 1}
									<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $row['id'],'status' => 0));}" class="btn btn-success btn-sm" title="系统自动判断" data-toggle="tooltip" data-placement="top">永久正常</a>
								{elseif $row['comm4status'] == 2}
									<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $row['id'],'status' => 1));}" class="btn btn-danger btn-sm" title="永久正常" data-toggle="tooltip" data-placement="top">自动锁定</a>
								{elseif $row['comm4status'] == 3}
									<a href="{php echo createWebUrl($do, array('op' => 'comm4status', 'themeid'=>$themeid,'id' => $row['id'],'status' => 0));}" class="btn btn-danger btn-sm" title="系统自动判断" data-toggle="tooltip" data-placement="top">手工锁定</a>
								{/if}
							</td>
							{/if} -->

							{if !empty($system['wxapp'])}
							<td>
								{php echo $system['wxapp']==$row['uniacid']?'小程序':'H5链接';}
							</td>
							{/if}
							<td style="text-align:right;">
								<a href="{php echo createWebUrl($do, array('op' => 'post', 'themeid'=>$themeid,'id' => $row['id']));}" class="btn btn-default btn-sm" title="修改" data-toggle="tooltip" data-placement="top"><i class="fa fa-edit"> </i></a>
								<a href="{php echo createWebUrl($do, array('op' => 'update', 'themeid'=>$themeid,'workerid' => $row['uid']));}" class="btn btn-default btn-sm"  data-toggle="tooltip" data-placement="top" onclick="if(!confirm('当数据不准确时可以更新，一般不需要此操作！')) return false;"  title="更新报表，当数据不准确时可以更新，一般不需要此操作！" ><i class="fa fa-refresh"> </i></a>
								<a href="{php echo createWebUrl($do, array('op' => 'delete', 'themeid'=>$themeid,'uid' => $row['uid']));}" class="btn btn-default btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
			{$pager}
			<div class="panel-footer">点击对应数字可查看对应明细; 直接客户数:客户通过员工链接直接付款的人数</div>
		</div>
	</form>
</div>

<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl($do, array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});		
			
		});
</script>

<!-- <div class="modal fade" id="clerk-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h3 class="modal-title">微信扫描二维码</h3>
			</div>
			<div class="modal-body" style="text-align: center">
				<img style="-webkit-user-select: none" src="{php echo createWebUrl('qr',array('url'=>createWebUrl('entry', array('themeid'=>$themeid,'m'=>MODULE_NAME, 'do'=>'w_init'), true, true)));}">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div> -->

{/if}
{if ($system['ruanjian']==3)}

    <script type="text/javascript">
        //定义省/直辖市数组
        var arr_province = ["请选择商家"{$compaytxt}];
        //定义市/区二维数组
        var arr_city = [
                        ["请左侧选择商家"]{$teamtxt}
                    ];
        //获取对象
        var province = document.getElementById('province');
        var city = document.getElementById('city');
        //初始化菜单
        onload = function () {
            //指定省option标记的个数
            province.length = arr_province.length;
            //数组数据写入<option>标记中

            var index = 0;
            company = '{php echo empty($company_txt)?"请选择商家":$company_txt;}';
            for(var i = 0; i < arr_province.length; i++){
                province.options[i].text = province.options[i].value = arr_province[i];
                if (arr_province[i] == company){
                	province.options[i].selected = true;
                	index=i;
                }
            }
            //设置省列表默认选项
            province.index = index;
            //指定城市option标记的个数
            city.length = arr_city[index].length;

            team = '{php echo empty($team_txt)?"请选择团队":$team_txt;}';
            //数组数据写入option标记
            for (var j = 0; j < arr_city[index].length; j++) {
                city.options[j].text = city.options[j].value = arr_city[index][j];
                if (arr_city[index][j] == team){
                	city.options[j].selected = true;  
                }
            }


        }
        function alter(index) {
            //修改省列表的选择项
            province.index = index;
            //指定城市option标记的个数
            city.length = arr_city[index].length;
            //数组中的数据写入option标记
            for (var j = 0; j < arr_city[index].length; j++) {
                city.options[j].text = city.options[j].value = arr_city[index][j];
            }
        }

    </script>
    {/if}
